#include <stdio.h>
#include "tinySH/shell.h"

int g_counter = 0;

NODE_FUN_DEF(counter_print, "pnt", 0, "It prints g_counter")
{
    printf("g_counter = %d\n", g_counter);
    return 0;
}

NODE_FUN_DEF(counter_inc, "inc", 0, "++ g_counter")
{
    ++ g_counter; 
    puts("==inc==");
    return 0;
}

NODE_FUN_DEF(counter_dec, "dec", 0, "-- g_counter")
{
    -- g_counter; 
    puts("==dec==");
    return 0;
}

NODE_FUN_DEF(counter_set, "set", 0, "set g_counter with value")
{
    int tmp = atoi(args);
    printf("set g_counter = %d\n", tmp);
    g_counter = tmp;
    return 0;
}

NODE_DIR_DEF(counter, "count",0,0)
{
    &counter_print,
    &counter_inc,
    &counter_dec,
    &counter_set,
    0
};

NODE_FUN_DEF(hello,"hello",0,"It say hi to you.")
{
    puts("====This hello function====");
    printf("Hi %s\n", args);
}

NODE_DIR_DEF(secret, "secret", "abc123", "It's need password. input:abc123")
{
    0
};

NODE_DIR_DEF(root,"root",0,0) 
{
    &hello,
    &counter,
    &secret,
    0
};

NODE_FUN(foo)
{
    puts("===foo in /sbin===");
}

NODE_DIR(sbin)
{
    &foo,
    0
};
